#import "MNBaseReq.h"
#import "MNBaseRsp.h"
#import "MNNetwork.h"

@implementation MNBaseReq

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.addToken = ETUSERINFO.loginDataModel?YES:NO;
    }
    return self;
}

- (NSString *)methodString {
    switch (self.method) {
        case ReqMethodGet:
            return @"GET";
        case ReqMethodPost:
            return @"POST";
        case ReqMethodPut:
            return @"PUT";
        case ReqMethodDelete:
            return @"DELETE";
        case ReqMethodUpload:
            return @"POST";
        default:
            return @"GET";
            break;
    }
}

+ (NSArray *)mj_ignoredPropertyNames
{
    NSMutableArray *arr = [NSMutableArray array];
    [MNBaseReq mj_enumerateProperties:^(MJProperty *property, BOOL *stop) {
        [arr addObject:property.name];
    }];
    return arr;
//    return @[@"reqUrl", @"rspClass", @"dataTask", @"routingPath", @"httpHeaders", @"timeoutInterval", @"method", @"_method", @"identifier", @"files"];
}

- (Class)rspClass
{
    if (_rspClass) {
        return _rspClass;
    }
    
    NSString *reqStr = NSStringFromClass([self class]);
    if ([reqStr hasSuffix:@"Req"]) {
        NSString *rspStr = [[reqStr substringToIndex:reqStr.length-3] stringByAppendingString:@"Rsp"];
        Class cls = NSClassFromString(rspStr);
        if (cls) {
            return cls;
        }
    }
    return [MNBaseRsp class];
}

- (NSMutableDictionary *)httpHeaders {
    if (!_httpHeaders) {
        _httpHeaders = [NSMutableDictionary dictionary];
    }
    return _httpHeaders;
}

- (NSMutableArray<MNUploadFile *> *)files {
    if (!_files) {
        _files = [NSMutableArray array];
    }
    return _files;
}

@end

@implementation MNUploadFile



@end


@implementation MNRemoteFile



@end
